//
//  ShakeViewController.m
//  KCZ_B段项目
//
//  Created by dllo on 15/11/4.
//  Copyright © 2015年 Sky. All rights reserved.
//

#import "ShakeViewController.h"
#import <AudioToolbox/AudioToolbox.h>
#import "ZJHShakeDetailViewController.h"
#import "FitHeader.h"
@interface ShakeViewController ()

@end

@implementation ShakeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor grayColor];
//    self.navigationController.navigationBar.translucent = NO;
    self.title = @"摇一摇";
#pragma mark 设置摇动
    [[UIApplication sharedApplication]setApplicationSupportsShakeToEdit:YES];
//    [self becomeFirstResponder];
}
-(void)loadView
{
    [super loadView];
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT - 64)];
    imageView.contentMode = UIViewContentModeScaleToFill;
    imageView.image = [UIImage imageNamed:@"yaoyiyao"];
//    UILabel *lable = [[UILabel alloc]initWithFrame:CGRectMake(100 , 250, 175, 63)];
//    lable.text = @"不知吃啥就摇一摇";
//    lable.font = [UIFont systemFontOfSize:20];
    [self.view addSubview:imageView];
    
}
#pragma mark 摇一摇震动
-(void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"shake"]) {
        
        AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
    }
}
#pragma mark 摇动结束
-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
    ZJHShakeDetailViewController *shakeDetailVC = [[ZJHShakeDetailViewController alloc]init];
    [shakeDetailVC setHidesBottomBarWhenPushed:YES];
    [self.navigationController pushViewController:shakeDetailVC animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
